#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#include <immintrin.h>
//#include <emmintrin.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define fi first
#define se second
#define pii pair<int,int>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=5e6+5,base=999983,Mod=998244353;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
inline void Add(int &x,int y){(x=x+y+Mod)%=Mod;}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,a[N];
pii ans[N];
int b[N]; 
signed main(){
	freopen("rotate.in","r",stdin);
	freopen("rotate.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read();
	For(i,1,n) a[i]=read();
//	n=2500;
//	For(i,1,n) a[i]=n-i+1 ;
	int x=(int)sqrt(n)+1;
	if(x%2==1)x++;
	int cnt=0;
	Rof(i,n,x){
		int id=0;
		For(j,1,n){
			if(a[j]==i)id=j;
		}
		while(id+x-1<=i){
			ans[++cnt]={1,id};
			For(i,id,id+x-2)swap(a[i],a[i+1]);
			id+=x-1;
		}
		if(id!=i){
			For(j,1,x-(i-id))ans[++cnt]={1,i-x+1};
			For(j,1,n) b[j]=a[j];
			For(j,i-x+1,id) b[i-id+j]=a[j];
			For(j,id+1,i) b[j-id-1+(i-x+1)]=a[j];
			For(j,1,n) a[j]=b[j];
		}
//		For(j,1,n) cout<<a[j]<<" ";
//		puts(""); 
	}
	
	For(j,1,x-1){
		if(a[j]!=j){
			For(i,j,a[j]-1){
				swap(a[i],a[i+1]);
				ans[++cnt]={2,i};
			}
		}
	} 
	printf("%lld ",x);
	printf("%lld\n",cnt);
	For(i,1,cnt) printf("%lld %lld\n",ans[i].fi,ans[i].se);
//int CNT=0;
//	For(i,1,cnt) if(ans[i].fi==2)printf("%lld %lld\n",ans[i].fi,ans[i].se),CNT++;
//	printf("%lld\n",CNT);
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

